/**  
* @Title: UDPClient.java  
* @Package cokeps  
* @Description: TODO(用一句话描述该文件做什么)  
* @author Mr.zhao  
* @date 2018年7月24日  
* @version V1.0  
*/ 
package cokeps;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @author Mr.zhao
 * @date 2018年7月24日
 *
 */
public class UDPClient {
	
	public static void main(String[] args) throws SocketException {
		DatagramSocket socket = new DatagramSocket();
		try {
		    String s = getJsonStr();
		    byte[] buf = s.getBytes();
		    //将数据打包
		    DatagramPacket packet; //114.55.233.51
			packet = new DatagramPacket(buf, buf.length, InetAddress.getByName("127.0.0.1"), 8086);
			socket.send(packet);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			socket.close();
		}
	}

	public  static String getJsonStr(){
//	   ScanCodeView scanCode = new ScanCodeView();
//	   scanCode.setCode("201707200549");
//	   scanCode.setWeight(53.0);
//	   return JSON.toJson(scanCode);
		return "ss";
	}
}
